package com.lzw.breezeNovel.webApp.mapper.video;

import com.lzw.breezeNovel.model.entity.pojo.video.VideoComment;
import com.lzw.breezeNovel.model.entity.query.video.CommnetQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.mapper.video
 * @date 2025/3/19
 * @description
 */
@Mapper
@SuppressWarnings("all")
public interface VideoCommentMapper {

    /**
     * 根据用户id和查询条件查询评论列表
     * @param userId
     * @param commnetQuery
     * @return
     */
    List<VideoComment> list(Long userId, CommnetQuery commnetQuery);

    /**
     * 插入评论
     * @param videoComment
     */
    void insert(VideoComment videoComment);

    /**
     * 更新点赞数
     * @param commentId
     * @param userId
     * @param type
     */
    @Update("update video_comment set likes = likes + 1 where comment_id = #{commentId} and user_id = #{userId} and type = #{type}")
    void updateLikeCountAdd(Long commentId, Long userId, Integer type);

    /**
     * 更新点赞数
     * @param commentId
     * @param userId
     * @param type
     */
    @Update("update video_comment set likes = likes- 1 where comment_id  = #{commentId} and user_id = #{userId} and type = #{type}")
    void updateLikeCountSub(Long commentId, Long userId, Integer type);

    /**
     * 分页查询评论
     * @param userId
     * @param startPage
     * @param size
     * @return
     */
    List<VideoComment> listByUserId(Long userId, int startPage, Integer size);

    /**
     * 逻辑删除评论
     * @param commentId
     */
    @Update("update video_comment set is_watch = 1 where comment_id = #{commentId}")
    void updateComment(Long commentId);

}
